﻿
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using BCCommon;
using System.Text;
using System.Net;
using Microsoft.AspNetCore.Mvc;
using BCDto.OA.WorkflowTemplate.WorkflowTemplateFormCustomDatabaseTable;
using BCTMSRESTful.Configs;
using BCService.Utils;
using BCService.OA.WorkflowTemplate.WorkflowTemplateFormCustomDatabaseTable;

namespace BCTMSRESTful.Controllers.Management.OA.WorkflowTemplate.WorkflowTemplateFormCustomDatabaseTable
{
    /// <summary>
    /// 工作流模板表单自定义数据库表集合
    /// </summary>
    [ApiExplorerSettings(GroupName = "OAAdmin")]
    [Route("api/v1/sim/[controller]")]
    public class WorkflowTemplateFormCustomDatabaseTableController : ManagementBaseController
    {
        private readonly IWorkflowTemplateFormCustomDatabaseTableService workflowTemplateFormCustomDatabaseTableService;

        public WorkflowTemplateFormCustomDatabaseTableController(IWorkflowTemplateFormCustomDatabaseTableService workflowTemplateFormCustomDatabaseTableService)
        {
            this.workflowTemplateFormCustomDatabaseTableService = workflowTemplateFormCustomDatabaseTableService;
        }

        #region 添加工作流模板表单自定义数据库表集合
        /// <summary>
        ///  添加工作流模板表单自定义数据库表集合
        /// </summary>
        /// <param name="requestDto">工作流模板表单自定义数据库表集合信息</param>
        /// <response code="201">添加工作流模板表单自定义数据库表集合成功</response>
        /// <response code="400">请求参数或输入的数据不正确。</response>
        /// <response code="500">服务器发生错误。</response>
        /// <response code="501">某些功能尚未实现。</response>
        /// <returns></returns>
        [HttpPost]
        [Log("添加工作流模板表单自定义数据库表集合")]
        [ProducesResponseType(typeof(WorkflowTemplateFormCustomDatabaseTableDto), 201)]
        public IActionResult Post(
            [FromBody] WorkflowTemplateFormCustomDatabaseTableRequestDto requestDto)
        {
            var result = this.workflowTemplateFormCustomDatabaseTableService.Add(requestDto);
            return StatusCode((int)HttpStatusCode.Created, result);
        }
        #endregion

        #region 修改工作流模板表单自定义数据库表集合
        /// <summary>
        ///  修改工作流模板表单自定义数据库表集合
        /// </summary>
        /// <param name="workflowTemplateFormCustomDatabaseTableId">工作流模板表单自定义数据库表集合Id</param>
        /// <param name="requestDto">工作流模板表单自定义数据库表集合信息</param>
        /// <response code="200">修改工作流模板表单自定义数据库表集合成功</response>
        /// <response code="400">请求参数或输入的数据不正确。</response>
        /// <response code="500">服务器发生错误。</response>
        /// <response code="501">某些功能尚未实现。</response>
        /// <returns></returns>
        [HttpPut("{workflow_template_form_custom_database_table_id}")]
        [Log("修改工作流模板表单自定义数据库表集合")]
        [ProducesResponseType(typeof(WorkflowTemplateFormCustomDatabaseTableDto), 200)]
        public IActionResult Put([FromRoute(Name = "workflow_template_form_custom_database_table_id")] long workflowTemplateFormCustomDatabaseTableId, [FromBody] WorkflowTemplateFormCustomDatabaseTableRequestDto requestDto)
        {
            WorkflowTemplateFormCustomDatabaseTablePutDto putDto = requestDto.As<WorkflowTemplateFormCustomDatabaseTablePutDto>();
            putDto.WorkflowTemplateFormCustomDatabaseTableId = workflowTemplateFormCustomDatabaseTableId;
            return StatusCode((int)HttpStatusCode.OK, this.workflowTemplateFormCustomDatabaseTableService.Update(putDto));
        }
        #endregion

        #region 删除工作流模板表单自定义数据库表集合
        /// <summary>
        ///  删除工作流模板表单自定义数据库表集合
        /// </summary>
        /// <param name="workflowTemplateFormCustomDatabaseTableId">工作流模板表单自定义数据库表集合Id</param>
        /// <response code="204">删除工作流模板表单自定义数据库表集合成功</response>
        /// <response code="400">请求参数或输入的数据不正确。</response>
        /// <response code="500">服务器发生错误。</response>
        /// <response code="501">某些功能尚未实现。</response>
        /// <returns></returns>
        [HttpDelete("{workflow_template_form_custom_database_table_id}")]
        [Log("删除工作流模板表单自定义数据库表集合")]
        [ProducesResponseType(typeof(NoContentResult), 204)]
        public IActionResult Delete([FromRoute(Name = "workflow_template_form_custom_database_table_id")] long workflowTemplateFormCustomDatabaseTableId)
        {
            this.workflowTemplateFormCustomDatabaseTableService.Delete(workflowTemplateFormCustomDatabaseTableId);
            return StatusCode((int)HttpStatusCode.NoContent);
        }
        #endregion

        #region 获取工作流模板表单自定义数据库表集合
        /// <summary>
        ///  获取工作流模板表单自定义数据库表集合
        /// </summary>
        /// <param name="workflowTemplateFormCustomDatabaseTableId">工作流模板表单自定义数据库表集合Id</param>
        /// <response code="200">获取工作流模板表单自定义数据库表集合</response>
        /// <response code="400">请求参数或输入的数据不正确。</response>
        /// <response code="500">服务器发生错误。</response>
        /// <response code="501">某些功能尚未实现。</response>
        /// <returns></returns>
        [HttpGet("{workflow_template_form_custom_database_table_id}")]
        [ProducesResponseType(typeof(WorkflowTemplateFormCustomDatabaseTableDto), 200)]
        public IActionResult Get([FromRoute(Name = "workflow_template_form_custom_database_table_id")] long workflowTemplateFormCustomDatabaseTableId)
        {
            return StatusCode((int)HttpStatusCode.OK, this.workflowTemplateFormCustomDatabaseTableService.Get(workflowTemplateFormCustomDatabaseTableId));
        }
        #endregion

        #region 获取工作流模板表单自定义数据库表集合列表
        /// <summary>
        ///  获取工作流模板表单自定义数据库表集合列表
        /// </summary>
        /// <param name="formConfigCode">表单配置Code</param>
        /// <response code="200">获取工作流模板表单自定义数据库表集合列表</response>
        /// <response code="400">请求参数或输入的数据不正确。</response>
        /// <response code="500">服务器发生错误。</response>
        /// <response code="501">某些功能尚未实现。</response>
        /// <returns></returns>
        [HttpGet("[action]/{form_config_code}")]
        [ProducesResponseType(typeof(WorkflowTemplateFormCustomDatabaseTableDto), 200)]
        public IActionResult List([FromRoute(Name = "form_config_code")] string formConfigCode)
        {
            return StatusCode((int)HttpStatusCode.OK, this.workflowTemplateFormCustomDatabaseTableService.GetList(formConfigCode));
        }
        #endregion

        #region 获取工作流模板表单自定义数据库表集合（分页）
        /// <summary>
        ///  获取工作流模板表单自定义数据库表集合（分页）
        /// </summary>
        /// <param name="start">开始时间</param>
        /// <param name="end">结束时间</param>
        /// <param name="sortName">排序字段</param>
        /// <param name="ascending">升序</param>
        /// <param name="pageIndex">当前页码</param>
        /// <param name="pageSize">当前页大小</param>
        /// <response code="200">获取工作流模板表单自定义数据库表集合（分页）</response>
        /// <response code="400">请求参数或输入的数据不正确。</response>
        /// <response code="500">服务器发生错误。</response>
        /// <response code="501">某些功能尚未实现。</response>
        /// <returns></returns>
        [HttpGet("[action]")]
        [ProducesResponseType(typeof(PageableList<WorkflowTemplateFormCustomDatabaseTableDto>), 200)]
        public IActionResult Query(
            [FromQuery(Name = "start")] DateTime? start,
            [FromQuery(Name = "end")] DateTime? end,
            [FromQuery(Name = "sort_name")] string sortName,
            [FromQuery(Name = "ascending")] bool? ascending,
            [FromQuery(Name = "page_index")] int pageIndex = 1,
            [FromQuery(Name = "page_size")] int pageSize = 10)
        {
            return StatusCode((int)HttpStatusCode.OK, this.workflowTemplateFormCustomDatabaseTableService.Query(start, end, sortName, ascending, pageIndex, pageSize));
        }
        #endregion
    }
}

